package com.robmayhew.jsc;





import java.io.FileFilter;
import java.io.File;
import java.util.StringTokenizer;

public class JavaFileFilter implements FileFilter
{
    private String[] ext;

    public JavaFileFilter(String extensions)
    {

        StringTokenizer st = new StringTokenizer(extensions, ",");
        ext = new String[st.countTokens()];
        int i = 0;
        while(st.hasMoreTokens())
        {
            ext[i] = st.nextToken();
            i++;
        }

    }

    public boolean accept(File pathName)
    {


        for(int i = 0; i < ext.length; i++){
            if(pathName.getName().endsWith(ext[i]))
            {
                return true;
            }
        }
        return false;
    }

}
